/******************************************************************************
 * SVN­Version­Information:
 * ­­­­­­­­­­­­­­­­­­­­­­­­---------------------
 * $LastChangedRevision: 6 $
 * $LastChangedBy: c.a.duevel $
 * $LastChangedDate: 2009-08-26 15:12:37 +0000 (Wed, 26 Aug 2009) $
 * $HeadURL: http://robofight.googlecode.com/svn/trunk/Server/test/de/hft_stuttgart/botwar/server/model/Helpers.java $
 *******************************************************************************/
package de.hft_stuttgart.botwar.server.model;

import de.hft_stuttgart.botwar.database.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import static de.hft_stuttgart.botwar.common.models.Position.*;
import static org.apache.commons.lang.RandomStringUtils.*;


/**
 *
 * @author c.a.duevel@gmail.com
 */
public class Helpers {
    static Random R = new Random();


    public static Robot createRandomRobot() {
        Armament arm = new Armament(random(5),5,5,5,5, 1);
        Shield shield = new Shield(random(5),3,3,3, 1);
        Chassis chassis = new Chassis(random(5), 4, shield.getWeight()
                + arm.getWeight(), 1, 1);
        
        RobotConfiguration conf = new RobotConfiguration(
                "test",
                createRandomPlayer(), chassis, shield, arm);
        return new Robot(conf, createRandomPosition());
    }
    public static Robot createRandomRobot(int speed, int range) {
        Armament arm = new Armament(random(5),5,range,5,5,1);
        Shield shield = new Shield(random(5),3,3,3,1);
        Chassis chassis = new Chassis(random(5), speed, shield.getWeight()
                + arm.getWeight(), 1, 1);

        RobotConfiguration conf = new RobotConfiguration(
                "test",
                createRandomPlayer(), chassis, shield, arm);
        return new Robot(conf, createRandomPosition());
    }
    public static Player createRandomPlayer(){
        return new Player(random(5),createRandomEmailAddress(),random(5));
    }
    public static String createRandomEmailAddress(){
        return random(5)+"@"+random(5)+".de";
    }

     static List<Robot> makeRobotList(Robot... robots){
        List<Robot> rList = new ArrayList<Robot>();
        for (Robot r: robots){
            rList.add(r);
        }
        return rList;
    }
     public static int getPosRandom(){
         return Math.abs(R.nextInt());
     }
     public static String getRandomString(){
         return getRandomString(10);
     }
     public static String getRandomString(final int length){
         return random(length);
     }
     public static int getRandom(){
         return R.nextInt();
     }




}
